<?php
	function f102($sql){
		//data handle instance
		//set request
		//define format
		//set format
		//define query string
		//process time
		//process fitler
		$dataHandle = new DataHandle();
		$dataHandle->setRequest("102");

		$format = array(
			"ModifiedDate" => "datem/d/Y",
			);

		$dataHandle->setFormat($format);

		$action = getValue($_GET['action']);

		if ($action == "getItems"){
			$error = $dataHandle->processTime($startTime, $endTime);
			if($error == ""){
				$filter = $dataHandle->processFilters($startTime, $endTime, "mix_Produced_Picking", "Date");
				$query = getJSONQuery($startTime, $endTime, $filter);
				print($dataHandle->printJSON($sql, $query));
			}
			else
				print($error);
		}
		else{
			$temp = array();
			$temp['error'] = "102: Bad request";
			print(json_encode($temp));
		}

		unset($dataHandle);

	}

	function getJSONQuery(&$startTime, &$endTime, &$filter){

		$queryString = "
			SELECT
				product_id,
				shift,
				start_time,
				end_time,
				Batch_No,
				Batch_Size,
				Picking,
				l1_user_name,
				modified_by,
				modified_date

			FROM 
				mix_Produced_Picking ";

		$queryString = $queryString.$filter;

		$oderByFiled = getValue($_GET['sortItem']);
		$oderByValue = getValue($_GET['ascDesc']);

		if($oderByFiled !== "" and $oderByValue !== "")
			$queryString = $queryString." order by ".$oderByFiled." ".$oderByValue;

		return $queryString;
	}
?>